package cn.jr.service.impl;


import cn.jr.dao.IOrderDao;
import cn.jr.dao.impl.OrderDaoImpl;
import cn.jr.pojo.Order;
import cn.jr.pojo.Wares;
import cn.jr.service.IOrderService;

import java.util.ArrayList;

@SuppressWarnings("all")
public class OrderServiceImpl implements IOrderService {

    IOrderDao iod =  new OrderDaoImpl();

    @Override //添加订单
    public boolean addOrder(String orderNumber,String orderTime) {
        Order order = new Order(orderNumber,orderTime);
        return iod.insertOrder(order)>0?true:false;
    }

    @Override //查询 一条订单 by 订单编号
    public Order getAnOrderbyOrderNumber(String orderNumber) {
        return iod.queryOrderByOrderNumber(orderNumber);
    }

    @Override //查询 订单表主键 by 订单编号
    public int getOrderIdByOrderNumber(String orderNumber) {
        return iod.queryOrderIdByOrderNumber(orderNumber);
    }

    @Override //查询 订单信息 by 订单表主键
    public Order getOrderById(int orderId) {
        ArrayList<Order> orders = new ArrayList<>();
        return iod.queryOrderById(orderId);
    }

    @Override //更新数据 -- 加钱/扣钱
    public boolean changeOrder(double waresAllPrice,double orderReallyPrice,int orderId) {
        return iod.updateOrder(waresAllPrice, orderReallyPrice, orderId)>0?true:false;
    }

    @Override //查询全部
    public ArrayList<Order> getAllOrderProject() {
        return iod.queryAllOrderProject();
    }
}
